<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*,com.device.operating.entity.User,com.device.operating.entity.Ugfunctype"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>网络设备统一操作平台</title>
<link rel="stylesheet" type="text/css" href="/xasj/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/xasj/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="/xasj/easyui/themes/color.css">
<script type="text/javascript" src="/xasj/easyui/jquery.min.js"></script>
<script type="text/javascript" src="/xasj/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/xasj/js/main.js"></script>
<style>
.panel-body{
	background:#f0f0f0;
}
.STYLE1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size: 16px;
	z-index:88;
	font-style:oblique;
}
.panel-header{
	background:#fff url('images/my/panel_header_bg.gif') no-repeat top right;
}
.panel-tool-collapse{
	background:url('images/my/arrow_up.gif') no-repeat 0px -3px;
}
.panel-tool-expand{
	background:url('images/my/arrow_down.gif') no-repeat 0px -3px;
}
</style>
<script type="text/javascript">
$(function(){
    var pager = $('#dg').datagrid().datagrid('getPager');    // get the pager of datagrid
    pager.pagination({
        buttons:[{
            iconCls:'icon-search',
            handler:function(){
                alert('search');
            }
        },{
            iconCls:'icon-add',
            handler:function(){
                alert('add');
            }
        },{
            iconCls:'icon-edit',
            handler:function(){
                alert('edit');
            }
        }]
    });            
})
/*	function addTab(title, url){
	    if ($('#tt').tabs('exists', title)){
	        $('#tt').tabs('select', title);
	    } else {
	        var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
	        $('#tt').tabs('add',{
	            title:title,
	            content:content,
	            closable:true,
	            iconCls:'icon-search',
	        });
	    }
	}
	*/
	function addTab(title, url,icon){
	    if ($('#tt').tabs('exists', title)){
	    	$('#tt').tabs('close',title);
	    }
        var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
        var icon='icon-'+icon;
        $('#tt').tabs('add',{
            title:title,
            content:content,
            closable:true,
            iconCls:icon,
        });
	}
	function removeTab(title){
		if ($('#tt').tabs('exists', title)){
			$('#tt').tabs('close',title);
			}
		}
	function loginout(){
		window.location.href='loginout';
	}
</script>

<% 
User user=(User)request.getSession().getAttribute("user");
List<Ugfunctype> listtype=(List<Ugfunctype>)request.getAttribute("listtype");
List<Ugfunctype> listjsp=(List<Ugfunctype>)request.getAttribute("listjsp");
%>
<input id="userId" value="<%=user.getUserId()%>" />
<body class="easyui-layout" >
        <div data-options="region:'north'" style="height:75px;background-color:#0074D3;z-index:1"><img src="/xasj/images/my/bt1.jpg" width="1230px"height="72px" />
        <div data-options="region:'south'" style="height:25px;"></div>
        <!--  <div data-options="region:'east',split:true" title="East" style="width:100px;">-->
        <!--<ul class="easyui-tree" data-options="url:'tree_data1.json',method:'get',animate:true,dnd:true"></ul> -->
        </div>
        <div data-options="region:'west',split:true"title="Menu" style="width:151px">
            <div class="easyui-accordion" data-options="fit:true,border:false,animate:false">
            	<%for(Ugfunctype uf:listtype){%>
            		<div title="<%=uf.getFunctypename()%>" style="padding:10px">
            		<%for(Ugfunctype ut:listjsp){
            			if(ut.getParentId().equals(uf.getFunctypeId())){%>
            				<a href="#" data-options="iconCls:'icon-<%=ut.getIconcls()%>',plain:true" onClick="javascript:addTab('<%=ut.getFunctypename()%>','<%=ut.getFunctypecode()%>','<%=ut.getIconcls()%>')" class="easyui-linkbutton" ><%=ut.getFunctypename()%></a><br>
            			<%}
            		}%>
            		
            		</div>
            	<%}%>
            </div>
        </div>
    </div>
        <div id ="tt"  class="easyui-tabs" data-options="region:'center'">
        </div>
         <div class="STYLE1" style="padding-top:32px;padding-left: 70%;position:absolute">
                          欢迎：<%=user.getUsername()%>&nbsp;&nbsp;&nbsp;工号：<%=user.getUsercode()%>&nbsp;&nbsp;&nbsp;<a href='#' onClick="javascript:loginout()" style="color: #FFFFFF;text-decoration: none">安全退出</a>>
        </div> 
        </div>
</body>

<script>
function setcrtpathcookie(){
	document.getElementById('file1').click();
	var  p_file_path=document.getElementById('file1').value;
    if(p_file_path!=null && p_file_path!=''  && p_file_path!='undefined'){ 
      setCookie('my_crt_path',p_file_path);
      alert('路径设置完毕 请重新打开');
    }else{
      alert('你没有选择CRT路径,所以无法启动!');
   	}
}

function setCookie(name,value)
{
    var Days = 30000000;
    var exp  = new Date();    //new Date("December 31, 9998");
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

function getCookie(sName){
// cookies are separated by semicolons
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++){
// a name/value pair (a crumb) is separated by an equal sign
	var aCrumb = aCookie[i].split("=");
	if (sName == aCrumb[0])
	return unescape(aCrumb[1]);
}
// a cookie with the requested name does not exist
	return null;
}

function RunExe(strPath,ip){
	try { 
	var file_path=strPath.replace(/\\/g,"/");
	var dir_path=file_path.substring(0,file_path.lastIndexOf("/")+1);
	runByVb(file_path,dir_path,ip); 
	}catch (e){
		alert('找不到文件路径和文件名不正确或者您的浏览器没有启用此ActiveX控件!');
		var r=confirm("重设CRT路径?"); 
		if(r == true){ 
			setcrtpathcookie();
		}   
	   }  
}
</script>

<script LANGUAGE="VBSCRIPT">
function runByVb(file_path,dir_path,ip)
Set objShell = CreateObject("WScript.Shell")
objShell.CurrentDirectory = dir_path
file_path=file_path+" "+ip
Set objWshScriptExec = objShell.Exec(file_path)
end function
</script>
<input type='file' id='file1' style="display: none" value=''/>
</html>